From: Colin Walters Date: Thu, 22 Jun 2017 17:01:50 +0000 (-0400) Subject: lib/core: Avoid NULL deref in content_file_parse() if out variable unset X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~35^2~70 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=aafda9073ad581f9b8051d58947bbab9379badcc;p=ostree.git lib/core: Avoid NULL deref in content_file_parse() if out variable unset Prep for a change in `ostree_repo_load_file()`. We would crash if a caller had `out_file_info = NULL`, because we deref `ret_file_info` below it. Closes: #951 Approved by: jlebon --- diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c index abc204e9..32516b7c 100644 --- a/src/libostree/ostree-core.c +++ b/src/libostree/ostree-core.c @@ -644,7 +644,7 @@ ostree_content_stream_parse (gboolean compressed, if (compressed) { if (!zlib_file_header_parse (file_header, - out_file_info ? &ret_file_info : NULL, + &ret_file_info, out_xattrs ? &ret_xattrs : NULL, error)) return FALSE; @@ -652,12 +652,11 @@ ostree_content_stream_parse (gboolean compressed, else { if (!file_header_parse (file_header, - out_file_info ? &ret_file_info : NULL, + &ret_file_info, out_xattrs ? &ret_xattrs : NULL, error)) return FALSE; - if (ret_file_info) - g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8); + g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8); } g_autoptr(GInputStream) ret_input = NULL;